package com.swjd.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.swjd.dao.TProductDao;
import com.swjd.pojo.TProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @author 刘涛
 * @create 2021/10/9 18:37
 */
@Controller
public class TProductController {
    @Autowired
    private TProductDao tProductDao;
    @RequestMapping("/productList")
    public String productList(Model model){
        QueryWrapper<TProduct> qw = new QueryWrapper<>();
        List<TProduct> tProducts = tProductDao.selectList(qw);
        model.addAttribute("tProducts",tProducts);
        return "ProductList.htm";
    }
    @RequestMapping("/select")
    public String select(Model model,String txtPname){
        QueryWrapper<TProduct> qw = new QueryWrapper<>();
        qw.like("Product_name",txtPname);
        List<TProduct> tProducts = tProductDao.selectList(qw);
        model.addAttribute("tProducts",tProducts);
        return "ProductList.htm";
    }
}
